package com.jsong.linuo.exception;

import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @Author: 黎诺
 * @CreateTime: 2025-04-28
 * @Description: 处理异常的方法01抛出异常
 */

public class Exception01 {
    public static void main(String[] args) throws Exception {
        String s = "a.txt1";
        add(s);
        delete();
    }

    private static void delete() {
        System.out.println("删除功能");
    }

    private static void add(String s) throws Exception{
        if (s==null){
            throw new IOException("IO异常");
        }
        if (!s.endsWith(".txt")){
            throw new FileNotFoundException("文件找不到");
        }

        System.out.println("添加功能");
    }
}
